package com.examples.ry.graphics;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;

public class GetSystemFont {
	public static void main(String[] args) {
		Display display = new Display();
		System.out.println("System Font is:");
		printFontData(display.getSystemFont().getFontData());
		System.out.println("Font in GC on Display is:");
		GC gc = new GC(display);
		printFontData(gc.getFont().getFontData());
		gc.dispose();
		display.dispose();
	}

	private static void printFontData(FontData[] fds) {
		String style;
		for (int i = 0; i < fds.length; ++i) {
			FontData fd = fds[i];
			switch (fd.getStyle()) {
			case SWT.NORMAL:
				style = "NORMAL";
				break;
			case SWT.BOLD:
				style = "BOLD";
				break;
			case SWT.ITALIC:
				style = "ITALIC";
				break;
			case (SWT.BOLD | SWT.ITALIC):
				style = "BOLD|ITALIC";
				break;
			default:
				style = "STYLE(" + fd.getStyle() + ")";
			}
			System.out.println(" FontData[" + i + "] " + fd.getName() + ", "
					+ fd.getHeight() + ", " + style);
		}
	}
}